package day4;

/**
 * @author oldliu
 * @since 1.0
 */
public class Student {
    //姓名，年龄和性别
    private String name;
    private int age;
    //男和女
    private String sex;
    public Student(){

    }

    public Student(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        //this.sex = sex;
        setSex(sex);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        if(!(sex.equals("男")||sex.equals("女"))){
            throw  new RuntimeException("性别:"+sex+"设置错误");
        }
        this.sex = sex;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                '}';
    }
}
